#include "Plugin/IPlugin.h"
#include "Plugin/PluginManager.h"

CallableContainer container;

#define PLUGIN_DEFINE(name) \
  class name : public IPlugin

#define PLUGIN_NAME(name) \
  std::string GetName() override { return #name; }

#define PLUGIN_EXPORT(name)                                           \
  using PluginType = name;                                            \
  PluginType plugin;                                                  \
  extern "C"                                                          \
  {                                                                   \
    __declspec(dllexport) IPlugin *CreatePlugin() { return &plugin; } \
  }

#define EXPORT_FUNC(funcName)                                                       \
  struct RegisterFunc_##funcName                                                    \
  {                                                                                 \
    RegisterFunc_##funcName(PluginType *plugin)                                     \
    {                                                                               \
      plugin->container.RegisterCallable(plugin, #funcName, &PluginType::funcName); \
    }                                                                               \
  };                                                                                \
  RegisterFunc_##funcName reg_##funcName(&plugin);